package com.cuicui.mall.controller;

import com.cuicui.mall.annotation.LogRecorder;
import com.cuicui.mall.service.GoodsClassifyService;
import com.cuicui.mall.utils.CommonResponse;
import com.cuicui.mall.vo.GoodsClassifyVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@Tag(name = "商品分类")
@RequestMapping("/goods_classify")
public class GoodsClassifyContoller {
    @Autowired
    private GoodsClassifyService goodsClassifyService;

    /**
     *
     * @param pageNo 页数
     * @param pageSize 单页数量
     * @return CommonResponse<GoodsVO>
     */
    @GetMapping("/getPage")
    @Operation(summary = "商品分类分页")
    @LogRecorder(operation = "商品分类分页")
    public CommonResponse getPage (Integer pageNo, Integer pageSize) {
        return goodsClassifyService.getPage(pageNo, pageSize);
    }

    /**
     *
     * @param goodsClassifyVO
     * @return
     */
    @PostMapping("/add")
    @Operation(summary = "新增商品分类")
    @LogRecorder(operation = "新增商品分类")
    public CommonResponse add (@RequestBody GoodsClassifyVO goodsClassifyVO) {
        return goodsClassifyService.add(goodsClassifyVO);
    }

    /**
     *
     * @param id
     * @return
     */
    @DeleteMapping("/remove")
    @Operation(summary = "删除商品分类")
    @LogRecorder(operation = "删除商品分类")
    public CommonResponse remove (@RequestBody(required = true) Integer id) {
        return goodsClassifyService.remove(id);
    }
}
